home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / slip_new.zip / TERMIN.ASM < prev    next >
Assembly Source File  |  1993-06-12  |  4KB  |  189 lines

  1. version    equ    1
  2.  
  3. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  4.  
  5. ;   This program is free software; you can redistribute it and/or modify
  6. ;   it under the terms of the GNU General Public License as published by
  7. ;   the Free Software Foundation, version 1.
  8. ;
  9. ;   This program is distributed in the hope that it will be useful,
  10. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ;   GNU General Public License for more details.
  13. ;
  14. ;   You should have received a copy of the GNU General Public License
  15. ;   along with this program; if not, write to the Free Software
  16. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.     include    defs.asm
  19.  
  20. code    segment word public
  21.     assume    cs:code, ds:code
  22.  
  23.     org    80h
  24. phd_dioa    label    byte
  25.  
  26.     org    100h
  27. start:
  28.     jmp    start_1
  29.  
  30. copyleft_msg    label    byte
  31.  db "Packet driver terminator version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version," copyright 1988-1992, Russell Nelson.",CR,LF
  32.  db "This program is free software; see the file COPYING for details.",CR,LF
  33.  db "NO WARRANTY; see the file COPYING for details.",CR,LF
  34. crlf_msg    db    CR,LF,'$'
  35.  
  36. their_isr    dd    ?
  37. entry_point    db    ?,?
  38.  
  39. handle        dw    ?
  40.  
  41. bogus_type    db    0,0        ;totally bogus type code.
  42.  
  43. signature    db    'PKT DRVR',0
  44. signature_len    equ    $-signature
  45.  
  46. flagbyte    db    0
  47. S_OPTION    equ    8
  48.  
  49. usage_msg        db    "usage: termin [-s] <packet_int_no>",'$'
  50. no_signature_msg    db    "termin: no packet driver at that address",'$'
  51. ok_msg            db    "termin: terminate completed",'$'
  52.  
  53. usage_error:
  54.     mov    dx,offset usage_msg
  55. error:
  56.     mov    ah,9
  57.     int    21h
  58.     int    20h
  59.  
  60. start_1:
  61.     cld
  62.  
  63.     mov    dx,offset copyleft_msg
  64.     mov    ah,9
  65.     int    21h
  66.  
  67.     mov    si,offset phd_dioa+1
  68.     call    skip_blanks        ;end of line?
  69.     cmp    al,CR
  70.     je    usage_error
  71.  
  72. chk_options:
  73.     call   skip_blanks
  74.     cmp    al,'-'            ; any options?
  75.     je    more_opt
  76.     cmp    al,'/'
  77.     jne    no_more_opt
  78. more_opt:
  79.     inc    si            ; skip past option char
  80.     lodsb                ; read next char
  81.     or    al,20h            ; convert to lower case
  82.     cmp    al,'s'
  83.     jne    usage_error
  84.     or    flagbyte,S_OPTION
  85.     jmp    chk_options
  86. no_more_opt:
  87.  
  88.     mov    di,offset entry_point
  89.     call    get_number
  90.  
  91.     mov    ah,35h            ;get their packet interrupt.
  92.     mov    al,entry_point
  93.     int    21h
  94.     mov    their_isr.offs,bx
  95.     mov    their_isr.segm,es
  96.  
  97.     lea    di,3[bx]
  98.     mov    si,offset signature
  99.     mov    cx,signature_len
  100.     repe    cmpsb
  101.     jne    no_signature_err
  102.  
  103.     mov    ax,1ffh            ;driver_info
  104.     call    int_pkt
  105.     call    fatal_error
  106.  
  107.     mov    ah,2            ;access_type
  108.     mov    al,ch            ;their class from driver_info().
  109.     mov    bx,dx            ;their type from driver_info().
  110.     mov    dl,cl            ;their number from driver_info().
  111.     mov    cx,2            ;use type length 2.
  112.     mov    si,offset bogus_type
  113.     movseg    es,cs
  114.     mov    di,offset our_recv
  115.     call    int_pkt
  116.     call    fatal_error
  117.     mov    handle,ax
  118.  
  119.     test    flagbyte,S_OPTION
  120.     jz    not_stop
  121.     mov    ah,8            ; f_stop
  122.     call    int_pkt
  123.     jmp    now_done
  124. not_stop:
  125.  
  126.  
  127.     mov    ah,5            ;terminate the driver.
  128.     mov    bx,handle
  129.     call    int_pkt
  130.     jnc    now_close
  131.     call    print_error
  132. now_close:
  133.     mov    ah,3            ;release_type
  134.     mov    bx,handle
  135.     call    int_pkt
  136.     jnc    now_done        ;if ok, we're done.
  137.     cmp    dh,BAD_HANDLE        ;if it succeeded, we'll get a bad handle.
  138.     je    now_done        ;it worked.
  139.     stc
  140.     call    fatal_error
  141.     int    20h
  142. now_done:
  143.         push    cs
  144.         pop     ds
  145.         lea     dx,ok_msg
  146.         mov     ah,9
  147.         int     21h
  148.         int     20h
  149.  
  150.  
  151. our_recv:
  152.     or    ax,ax            ;first or second call?
  153.     jne    our_recv_1        ;second -- we ignore the packet
  154.     movseg    es,cs
  155.     mov    di,offset our_buffer
  156. our_recv_1:
  157.     retf
  158.  
  159.  
  160. no_signature_err:
  161.     mov    dx,offset no_signature_msg
  162.     mov    ah,9
  163.     int    21h
  164.     int    20h
  165.  
  166.  
  167. int_pkt:
  168.     push    ds
  169.     push    es
  170.     pushf
  171.     cli
  172.     call    their_isr
  173.     pop    es
  174.     pop    ds
  175.     ret
  176.  
  177.  
  178.     include    pkterr.asm
  179.     include    getnum.asm
  180.     include    skipblk.asm
  181.     include    getdig.asm
  182.     include    chrout.asm
  183.  
  184. our_buffer    label    byte
  185.  
  186. code    ends
  187.  
  188.     end    start
  189.